package com.example.testspringwebflux;

import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.CharBuffer;

/**
 * ClientMain
 *
 * @author xule
 * @since 2024/07/08
 */
public class ClientMain {

    public static void main(String[] args) throws Exception {
        Socket socket = new Socket();
        socket.connect(new InetSocketAddress("192.168.60.49", 8080));

        PrintStream printStream = new PrintStream(socket.getOutputStream());
        printStream.println("this is client request");

        InputStreamReader reader = new InputStreamReader(socket.getInputStream());
        CharBuffer wrap = CharBuffer.wrap(new char[1024]);
        if ((reader.read(wrap)) != -1) {

            System.out.println("客户端收到消息:" +  wrap.slice(0, wrap.position()));
        }
        reader.close();
        socket.close();
    }
}
